package com.myhome.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.myhome.domain.Market;
import com.myhome.mapper.MarketMapper;
import com.myhome.service.MarketService;
/**
*@Author QYiXin 
* @Date 2021 11 01 17 20
**/
@Service
public class MarketServiceImpl extends ServiceImpl<MarketMapper, Market> implements MarketService{

    @Override
    public Page<Market> findByPage(Page<Market> page, Long tradeAreaId, Byte status) {
        return this.page(page, new LambdaQueryWrapper<Market>().eq(tradeAreaId != null, Market::getTradeAreaId, tradeAreaId).eq(status != null, Market::getStatus, status));
    }

    @Override
    public List<Market> getMarkersByTradeAreaId(Long id) {
        return list(new LambdaQueryWrapper<Market>()
                .eq(Market::getTradeAreaId, id)
                .eq(Market::getStatus, 1)
                .orderByAsc(Market::getSort)
        );
    }

    @Override
    public Market getMarkerBySymbol(String symbol) {
        return this.getOne(new LambdaQueryWrapper<Market>().eq(symbol != null, Market::getSymbol, symbol));
    }


}
